package com.ruoyi.web.controller.system;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TProprietor;
import com.ruoyi.web.controller.tool.face.CreatePerson;
import com.ruoyi.web.controller.tool.face.DeletePersonFromGroup;
import com.ruoyi.web.controller.tool.face.GetPersonList;
import com.ruoyi.web.controller.tool.face.SearchFaces;
import com.sun.xml.internal.fastinfoset.util.StringIntMap;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/face")
public class FaceController {
//    查人员库
    @PreAuthorize("@ss.hasPermi('system:face:list')")
    @GetMapping("/list")
    public String list() throws TencentCloudSDKException {
        String  get= GetPersonList.personnels();
//        System.out.println("查人员库"+get);
        return get;
    }
//    创建人员
    @PreAuthorize("@ss.hasPermi('system:face:create')")
    @PostMapping("/create")
    public String create(String PersonName,String PersonId,Long Gender,String Image) throws TencentCloudSDKException {
        String  create= CreatePerson.craeteperson(PersonName,PersonId,Gender,Image);
        System.out.println("创建人员"+create);
        return create;
    }
//    人脸搜索
    @PreAuthorize("@ss.hasPermi('system:face:search')")
    @PostMapping
//    @ResponseBody
    public String search(@RequestBody String Image) throws TencentCloudSDKException {
//        System.out.println("人脸识别数据"+Image);
        String  search= SearchFaces.searchfaces(Image);
        System.out.println("人脸搜索"+search);
        return search;
    }
//删除人员
    @PreAuthorize("@ss.hasPermi('system:face:delete')")
    @DeleteMapping("{PersonId}")
    public String delete(@PathVariable("PersonId") String PersonId) throws TencentCloudSDKException{
        String delete= DeletePersonFromGroup.deleteperson(PersonId);
        System.out.println(delete);
        return delete;
    }
}
